/*
 * 本类负责从服务器下载数据
 * 2011-11-07:completed initially by gongshw
 */
package nju.mscs.data;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.Socket;
import java.net.UnknownHostException;

import nju.mscs.data.object.Database;

public class NetClientManager extends NetManager{
	public NetClientManager(){
		
	}
	
	
	public Database getDatabase(String shopId) throws UnknownHostException, IOException, ClassNotFoundException{
		String serverip = Configration.getIniKey("serverip");
		int serverport = Integer.parseInt(Configration.getIniKey("serverportdown"));
		System.out.println(serverip+":"+serverport);
		Socket socket = new Socket(serverip,serverport);
		writeToSocket(shopId,socket);
		Database database =(Database) this.readFromSocket(socket);
		socket.close();
		return database;
	}
	public void upload(String shopId,Database db) throws UnknownHostException, IOException{
		String serverip = Configration.getIniKey("serverip");
		int serverport = Integer.parseInt(Configration.getIniKey("serverportup"));
		System.out.println(serverip+":"+serverport);
		Socket socket = new Socket(serverip,serverport);
		this.writeToSocket(db, socket);
	}
}
